<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="renderer" content="webkit">
    <link rel="stylesheet" href="/mdui/css/mdui.min.css">
    <script defer src="/mdui/js/mdui.min.js"></script>
    <script src="/js/axios.min.js"></script>
    <script src="/js/qs.min.js"></script>
    <script src="/js/common.js"></script>
    <script src="/js/vue.js"></script>
    <style>

    </style>
</head>
<body class="mdui-theme-primary-indigo mdui-theme-accent-pink">
<div class="mdui-container-fluid" id="app">
    <h1 class="mdui-text-color-theme">修改信息</h1>
    <!-- 固定标签 -->
    <form>
        <div class="mdui-textfield">
            <i class="mdui-icon material-icons">account_circle</i>
            <label class="mdui-textfield-label">姓名</label>
            <input class=" mdui-textfield-input" type="text" v-model="name" name="name"/>
        </div>
        <!-- 固定标签 -->
        <div class="mdui-textfield">
            <i class="mdui-icon material-icons">email</i>
            <label class="mdui-textfield-label">邮箱</label>
            <input class="mdui-textfield-input" type="text" v-model="email" name="email"/>
        </div>
        <!-- 固定标签 -->
        <div class="mdui-textfield">
            <i class="mdui-icon material-icons">phone</i>
            <label class="mdui-textfield-label">电话</label>
            <input class="mdui-textfield-input" type="text" v-model="phone" name="phone"/>
        </div>
        <!-- 固定标签 -->
        <div class="mdui-textfield">
            <i class="mdui-icon material-icons">place</i>
            <label class="mdui-textfield-label">宿舍</label>
            <input class="mdui-textfield-input" type="text" v-model="door" name="door"/>
        </div>
        <!-- 固定标签 -->
        <div class="mdui-textfield">
            <i class="mdui-icon material-icons">photo</i>
            <label class="mdui-textfield-label">上传头像</label>
            <input class=" mdui-textfield-input" type="file" id="file" name="file" placeholder="上传头像"/>
        </div>
    </form>

    <div style="text-align: center">
        <button @click="updateStudent" class="mdui-btn mdui-btn-raised mdui-ripple mdui-color-green-800">提交</button>
        <a href="list.html" class="mdui-btn mdui-btn-raised mdui-ripple mdui-color-green-800">返回</a>
    </div>
</div>
<script>
    new Vue({
        el: '#app',
        data: {
            id: '',
            name: "",
            sexual: "",
            email: "",
            phone: "",
            door: "",
            pic: ""
        },
        created() {
            let _this = this
            axios.get("/student/findStudent")
                .then(function (res) {
                    console.log(res.data.id)
                    _this.id = res.data.id;
                    _this.name = res.data.name;
                    _this.sexual = res.data.sexual;
                    _this.email = res.data.email;
                    _this.phone = res.data.phone;
                    _this.door = res.data.door;
                    _this.pic = res.data.pic;
                })
        },
        methods: {
            updateStudent() {
                let _this = this;
                let fd = new FormData(document.forms[0])//form里的输入框要有name属性
                axios.post("/student/saveStudent", fd)
                    .then(function (res) {
                        if (res.data.success) {
                            mdui.alert("更改成功");
                        }
                    })
            }
        }
    })
</script>
</body>
</html>